import java.util.List;

public class DeleteCommand implements Command {

    private final Genome genome;
    private final int genomeIdx;
    private final int startBlock;
    private final int endBlock;
    private List<Integer> deleted;

    public DeleteCommand(int genomeIdx, Genome genome, int startBlock, int endBlock) {
        this.genomeIdx = genomeIdx;
        this.genome = genome;
        this.startBlock = startBlock;
        this.endBlock = endBlock;
    }

    @Override
    public void execute() throws ParametersException {
        deleted = genome.delete(startBlock, endBlock);
    }

    @Override
    public void undo() throws ParametersException {
        if (deleted != null) {
            genome.insert(startBlock, deleted);
        }
    }

    @Override
    public String toString() {
        return "delete " + genomeIdx + " " + startBlock + " " + endBlock;
    }
}
